<template>
	<view>
		<button type="primary" @click="goinviteCode" v-if="isauditshow">邀请用户</button>
		<button type="primary" @click="goaudit" style="margin-top: 30rpx;" v-if="isauditshow">审核申请</button>
		<button class="logout" type="warn" @click="logout">退出登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		computed: {
			isauditshow() {
				if(this.$store.state.userInfo.role === 1) return true
				return false
			}
		},
		methods: {
			logout() {
				uni.showModal({
					title: '确定退出登录么',
					content: '下次访问将重新登录',
					success: function(res) {
						if (res.confirm) {
							uni.showToast({
								title: '已退出',
								success() {
									uni.removeStorageSync('token')
									setTimeout(() => {
										uni.navigateTo({
											url: '/pages/login/login'
										})
									}, 500)
				  		}
							})
						} else if (res.cancel) {
				   console.log('用户点击取消');
						}
					}
				});

			},
			goinviteCode() {
				uni.navigateTo({
					url:'/pages/inviteCode/inviteCode'
				})
			},
			goaudit(){
				uni.navigateTo({
					url: '/pages/audit/audit'
				})
			}
		}
	}
</script>

<style lang="less">
	.logout {
		position: absolute;
		left: 50%;
		bottom: 50rpx;
		transform: translateX(-50%);
		width: 60%;
		line-height: 80rpx;
	}
</style>
